﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using WebApi.Helpers;

namespace WebApi
{
    public class WeighService
    {
        /// <summary>
        /// 获取分页列表
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public async Task<List<WeighInfoVM>> GetPageListAsync(Expression<Func<WeighInfoVM, bool>> filter, int pageIndex, int pageSize, SqlSugar.RefAsync<int> totalCount)
        {
            return await DbHelper.GetDbConn().SqlQueryable<WeighInfoVM>("SELECT wr.*,m.GrossWeight MonitorGrossWeight,m.TareWeight MonitorTareWeight,ri.RegPhone FROM t_WeightRecord wr left join t_Monitor m on wr.Predefined15=m.Id left join t_RegisterInfo ri on wr.Guid=ri.Guid").Where(filter).OrderBy(it => it.UpdateTime, SqlSugar.OrderByType.Desc).ToPageListAsync(pageIndex, pageSize, totalCount);
        }
    }
}